<%
var entityName = "角色";
var baseUrl = BASE+"/admin/sys/role";
%>
<div id="tab-system" class="HuiTab">
	<div class="tabBar cl">
		<span class="current">${entityName}列表</span>
		<span onclick="HtmlRender('${baseUrl}/add')">添加${entityName}</span>
	</div>
	<br>
</div>
<div>
  <form action="${baseUrl}/list" id="form_pager_search" method="post">
	<input type="text" class="input-text" style="width:200px" placeholder="输入角色名称" id="_s_name" name="_s_name" value="${searchKeys.name!}" >
	<button type="button" class="btn btn-success" onclick="list_search()"><i class="Hui-iconfont">&#xe665;</i> 查找</button>
  </form>
</div>
<div class="cl pd-5 bg-1 bk-gray mt-20"> 
	<span class="l">
		<a href="javascript:;" onclick="list_del()" class="btn btn-danger size-S radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
	</span>
</div>
<table id="ttt" class="table table-border table-bordered table-bg">
	<thead>
		<tr class="text-c"><th width="25"><input type="checkbox" name="" value=""></th>
	<th width="40">ID</th>
	<th>角色名称</th>
	<th>描述</th>
	<th>状态</th><th>操作</th></tr>
	</thead>
	<tbody></tbody>
</table>
<script type="text/javascript">
function list_del(id){
	var select_ids = "";
	if(id){
		select_ids=id;
	}else{
	    $("input[name='table_checkbox_id']:checked").each(function(){
	    	select_ids+=$(this).val()+",";   
	    });
	    if(""==select_ids){
	    	layer.msg('请先选择要删除的数据！', {icon: 3,offset: '45px'});
	    	return false;
	    }
	}
	layer.confirm('确认删除所选记录?', {icon: 3, title:'警告'}, function(index){	    
	    layer.close(index);
	    HtmlRender("${baseUrl}/del",{ids:select_ids});
	});
}
function list_edit(id,state){
    HtmlRender("${baseUrl}/edit",{id:id});
}
function list_search(){
	var $form = $("#form_pager_search");
	var url = $form.attr('action');
	var $input  = $("<input type='hidden' name='_sbtn' value='true' />");
	$form.append($input);
    HtmlRender(url,$form.serializeArray());
}
function list_setState(id,state){
	HtmlRender("${BASE}/admin/sys/role/setState",{id:id,state:state});
}

$(function(){
	$("#ttt").dataTable({
        "serverSide": true,
        "ajax": "${BASE}/admin/sys/role/listData",
        "columns": [
                    { "data": "id",name:"KKK" },
                    { "data": "id" },
            { "data": "name" },
            { "data": "state" },
            { "data": "summary" },
            { "class":          "td-manage",
            	"render": function(data, type, row) {
                return '<a class="btn btn-secondary size-MINI" href="javascript:;" title="编辑" onclick="list_edit(\''+row[1]+'\')"><i class="Hui-iconfont">&#xe6df;</i> 编辑</a><a class="btn btn-danger size-MINI" href="javascript:;" title="删除" onclick="list_del(\'1\')"><i class="Hui-iconfont">&#xe6e2;</i> 删除</a>';
            } }]
	});
	table_checkbox_all();
})
</script>